package com.itheima.manager;

import com.itheima.domain.SmsFlashPromotion;
import com.itheima.service.db.SmsFlashPromotionService;
import com.itheima.util.R;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

@Component
public class SmsFlashManager {

    @DubboReference
    SmsFlashPromotionService smsFlashPromotionService;

    public R findByPage(Integer pageNum, Integer pageSize, String keyword) {
        return R.success(smsFlashPromotionService.findByPage(pageNum, pageSize, keyword));
    }

    public R updateStatusById(Long id, Integer status) {
        //根据id查询当前用户
        SmsFlashPromotion smsFlashPromotion = smsFlashPromotionService.findById(id);

        //设置状态
        smsFlashPromotion.setStatus(status);

        //更新数据
        smsFlashPromotionService.update(smsFlashPromotion);

        return R.success(null);
    }

    public R updateById(SmsFlashPromotion smsFlashPromotion) {
        smsFlashPromotionService.update(smsFlashPromotion);
        return R.success(null);
    }

    public R deleteById(Long id) {
        smsFlashPromotionService.deleteById(id);
        return R.success(null);
    }

    public R create(SmsFlashPromotion smsFlashPromotion) {
        return R.success(smsFlashPromotionService.create(smsFlashPromotion));

    }
}
